'use strict';

define(['controllers'], function (controllers) {
    controllers.common.controller('GlobalController', ['$scope', '$rootScope', function ($scope, $rootScope) {
        $rootScope.STAT_TYPE_HOUR = 'HOUR';
        $rootScope.STAT_TYPE_DAY = 'DAY';
        $rootScope.STAT_TYPE_MONTH = 'MONTH';

        $rootScope.DIMENSION_NODE = 1;
        $rootScope.DIMENSION_COLLECTION = 2;
        $rootScope.DIMENSION_REPLICA = 3;

        $rootScope.STATE_LEADER = 'LEADER';
        $rootScope.STATE_ACTIVE = 'ACTIVE';
        $rootScope.STATE_RECOVERING = 'RECOVERING';
        $rootScope.STATE_DOWN = 'DOWN';
        $rootScope.STATE_RECOVERY_FAILED = 'RECOVERY_FAILED';
        $rootScope.STATE_GONE = 'GONE';

        $rootScope.DATE_FORMAT = 'yyyy-MM-dd';
        $rootScope.TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';

        $rootScope.formatStatTime = function (time, statType) {
            if ($rootScope.STAT_TYPE_HOUR == statType) {
                return new Date(time).format('dd日HH点');
            } else if ($rootScope.STAT_TYPE_DAY == statType) {
                return new Date(time).format('MM月dd日');
            } else if ($rootScope.STAT_TYPE_DAY == statType) {
                return new Date(time).format('yyyy年MM月');
            }
        };
    }]);
});